package com.qumoyugo.springframework.util;

/**
 * @author Cedric
 * @date 2021/11/23 10:15
 * @description 获取类加载器
 */
public class ClassUtils {

    public static ClassLoader getDefaultClassLoader() {
        ClassLoader cl = null;
        try {
            cl = Thread.currentThread().getContextClassLoader();
        } catch (Throwable ex) {
            // 从线程上下文获取失败则从当前类加载
        }
        if (cl == null) {
            cl = ClassUtils.class.getClassLoader();
        }
        return cl;
    }
}
